package me.firesun.wechat.enhancement.plugin;


import android.app.AndroidAppHelper;
import android.content.Context;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import me.firesun.wechat.enhancement.PreferencesUtils;
import me.firesun.wechat.enhancement.util.HookParams;


public class AddFriendByScanMobile implements IPlugin {
    @Override
    public void hook(XC_LoadPackage.LoadPackageParam lpparam) {
        XposedHelpers.findAndHookMethod(HookParams.getInstance().LauncherUIClassName, lpparam.classLoader, HookParams.getInstance().LauncherUIMethod, Menu.class, new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                super.beforeHookedMethod(param);
                final Context context = AndroidAppHelper.currentApplication().getApplicationContext();
                Menu menu = (Menu) param.args[0];
                menu.add(0, 3, 0, "扫手机号添加好友");
                menu.getItem(0).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
                    @Override
                    public boolean onMenuItemClick(MenuItem menuItem) {
                        XposedBridge.log("点击扫手机号添加好友按钮");
                        Toast.makeText(context, "点击扫手机号添加好友按钮", Toast.LENGTH_SHORT).show();
                        return false;
                    }
                });
            }
        });
    }

}
